//hwincomcontrolsite.h
#pragma once
#ifndef __HWINCOMCONTROLSITE_H__
#define __HWINCOMCONTROLSITE_H__

#include "hwincontrol.h"
#include "hwinobjimpl.h"
#include "hwincomobject.h"

namespace harlinn
{
    namespace windows
    {
        class ComControlSite : public ComObject,
            IOleClientSiteImpl<ComControlSite>,
            IOleControlSiteImpl<ComControlSite>,
            IOleInPlaceSiteImpl<ComControlSite>,
            IAdviseSinkImpl<ComControlSite>,
            IOleDocumentSiteImpl<ComControlSite>,
            IOleUIObjInfoImpl<ComControlSite>
        {
        public:
            
            

            typedef ComObject Base;
            ComControlSite( std::shared_ptr<Control> theControl )
                : Base(theControl),
                  IOleClientSiteImpl<ComControlSite>(this),
                  IOleControlSiteImpl<ComControlSite>(this),
                  IOleInPlaceSiteImpl<ComControlSite>(this),
                  IAdviseSinkImpl<ComControlSite>(this),
                  IOleDocumentSiteImpl<ComControlSite>(this),
                  IOleUIObjInfoImpl<ComControlSite>(this)
            {}


            virtual HRESULT QueryInterface( REFIID riid,void ** ppvObject)
            {
                return Base::QueryInterface( riid,ppvObject);
            }

            virtual ULONG STDMETHODCALLTYPE AddRef( )
            {
                return Base::AddRef( );
            }

            virtual ULONG STDMETHODCALLTYPE Release( )
            {
                return Base::Release( );
            }

            // IOleWindow
            HWIN_EXPORT HRESULT GetWindow(HWND *phwnd);
            HWIN_EXPORT HRESULT ContextSensitiveHelp(BOOL fEnterMode);

            // IOleClientSite
            HWIN_EXPORT HRESULT SaveObject( );
            HWIN_EXPORT HRESULT GetMoniker( DWORD dwAssign,DWORD dwWhichMoniker,IMoniker **ppmk);
            HWIN_EXPORT HRESULT GetContainer( IOleContainer **ppContainer);
            HWIN_EXPORT HRESULT ShowObject( );
            HWIN_EXPORT HRESULT OnShowWindow( BOOL fShow);
            HWIN_EXPORT HRESULT RequestNewObjectLayout( );

            // IOleControlSite
            HWIN_EXPORT HRESULT OnControlInfoChanged( );
            HWIN_EXPORT HRESULT LockInPlaceActive( BOOL fLock);
            HWIN_EXPORT HRESULT GetExtendedControl( IDispatch **ppDisp);
            HWIN_EXPORT HRESULT TransformCoords( POINTL *pPtlHimetric,POINTF *pPtfContainer, DWORD dwFlags);
            HWIN_EXPORT HRESULT TranslateAccelerator( MSG *pMsg,DWORD grfModifiers);
            HWIN_EXPORT HRESULT OnFocus( BOOL fGotFocus);
            HWIN_EXPORT HRESULT ShowPropertyFrame( );

            HWIN_EXPORT HRESULT CanInPlaceActivate( );
            HWIN_EXPORT HRESULT OnInPlaceActivate( );
            HWIN_EXPORT HRESULT OnUIActivate( );
            HWIN_EXPORT HRESULT GetWindowContext( IOleInPlaceFrame **ppFrame,IOleInPlaceUIWindow **ppDoc,LPRECT lprcPosRect,LPRECT lprcClipRect,LPOLEINPLACEFRAMEINFO lpFrameInfo);
            HWIN_EXPORT HRESULT Scroll( SIZE scrollExtant);
            HWIN_EXPORT HRESULT OnUIDeactivate( BOOL fUndoable);
            HWIN_EXPORT HRESULT OnInPlaceDeactivate( );
            HWIN_EXPORT HRESULT DiscardUndoState( );
            HWIN_EXPORT HRESULT DeactivateAndUndo( );
            HWIN_EXPORT HRESULT OnPosRectChange( LPCRECT lprcPosRect);

            // IAdviseSinkImpl
            HWIN_EXPORT void OnDataChange( FORMATETC *pFormatetc,STGMEDIUM *pStgmed);
            HWIN_EXPORT void OnViewChange( DWORD dwAspect,LONG lindex);
            HWIN_EXPORT void OnRename( IMoniker *pmk);
            HWIN_EXPORT void OnSave( );
            HWIN_EXPORT void OnClose( );

            // IOleUIObjInfo
            HWIN_EXPORT HRESULT GetObjectInfo(DWORD dwObject,DWORD* lpdwObjSize, LPWSTR * lplpszLabel,LPWSTR FAR* lplpszType, LPWSTR * lplpszShortType,LPWSTR * lplpszLocation);
            HWIN_EXPORT HRESULT GetConvertInfo(DWORD dwObject,
                                                CLSID * lpClassID, WORD * lpwFormat,
                                                CLSID * lpConvertDefaultClassID,
                                                LPCLSID * lplpClsidExclude, UINT * lpcClsidExclude);
            HWIN_EXPORT HRESULT ConvertObject(DWORD dwObject, REFCLSID clsidNew);
            
            HWIN_EXPORT HRESULT GetViewInfo (DWORD dwObject,HGLOBAL * phMetaPict, DWORD* pdvAspect, int* pnCurrentScale);
            HWIN_EXPORT HRESULT SetViewInfo (DWORD dwObject,HGLOBAL hMetaPict, DWORD dvAspect,int nCurrentScale, BOOL bRelativeToOrig);

            // IOleDocumentSite
            HWIN_EXPORT HRESULT ActivateMe(IOleDocumentView *pViewToActivate);



        };
    }
}


#endif //hwincomcontrolsite.h

